<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <meta name="format-detection" content="address=no" />
    <meta name="format-detection" content="date=no" />
    <title>选择身份</title>
    <link href="../../css/api.css" rel="stylesheet" type="text/css">
    <link href="../../css/index.css" rel="stylesheet" type="text/css">
    <link href="../../css/data-flex.min.css" rel="stylesheet" type="text/css">
    <style>
        body {
            width: 100vw;
            height: 100vh;
        }

        .bg {
            width: 100%;
            height: 100%;
            background: url("../../image/ui/bg_7.png");
            background-size: 100% 100%;
        }

        header {
            height: 44px;
            box-sizing: content-box;
        }

        .back {
            width: 44px;
            height: 44px;
        }

        .title {
            font-size: 18px;
            font-weight: 500;
            color: rgba(255, 255, 255, 1);
        }

        .right-btn {
            width: 44px;
        }

        .img {
            width: 100px;
            height: 100px;
            margin: 60px auto 0 auto;
        }

        .btn {
            margin: 25px auto 0 auto;
            width: 150px;
            height: 46px;
            background: url("../../image/ui/btn_5.png");
            background-size: 100% 100%;
            padding-top: 8px;
            text-align: center;
            font-size: 18px;
            font-weight: 600;
            color: rgba(124, 69, 0, 1);
            line-height: 25px;
        }
    </style>
</head>

<body class="blue-bg">
    <div class="bg vueApp" v-cloak>
        <header data-flex="main:justify cross:center">
            <div class="back" tapmode onclick="fnBack()">
                <img src="../../image/ui/back.png" alt="">
            </div>
            <div class="title">
                请选择身份
            </div>
            <div class="right-btn"></div>
        </header>
        <div class="img">
            <img src="../../image/ui/id_student.png" alt="">
        </div>
        <div onclick="handleId(1)" class="btn">我是学生</div>
        <div class="img">
            <img src="../../image/ui/id_teacher.png" alt="">
        </div>
        <div onclick="handleId(2)" class="btn">我是老师</div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-font.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-login.js"></script>
<script type="text/javascript" src="../../script/service/service-verify.js"></script>
<script>
    var $S;
    var USER;
    var type;
    var pageParam = {}, loginPageParams = {};
    apiready = function () {
        $S = SERVICE();
        USER = USER();
        pageParam = api.pageParam;
        loginPageParams = pageParam.loginPageParams || {};
        fnInit();
    }

    function fnInit() {
        vm = new Vue({
            el: ".vueApp"
        })
    }

    function handleId(sender) {
        type = sender;
        fnOpenAlert({
            alertType: 1,
            alertConfirmFn: 'confirm'
        })
    }

    function confirm() {
        $S.ShowProgress();
        var postData = {
            "phone": pageParam.phone,
            "password": pageParam.password || '',
            "code": pageParam.code,
            "userType": type,
            "thirdType": loginPageParams.thirdType,
            "thirdPartyId": loginPageParams.threeLoginId || '',
            "nickname": loginPageParams.nickName || '',
            "icon": loginPageParams.avatar || ''
        };
        // 用户注册
        $S.POST('apiTbAppUser/addUserSignRegister', postData, function(ret,err) {
            $S.CloseProgress();
            if(ret && ret.status == '200') {
                var data = ret.data;
                data.memberType = type;
                fnWhenLoginSucess(data);
                fnToast("注册成功");
                var param = {
                    type: type,
                    isBack: false,
                    isSlidBack: false
                };
                // fnToast("您选择的身份是" + (type === 2 ? '学生' : '老师'));
                fnOpenPublicWin('完善信息', 'login/perfect_data', param);
            } else {
                console.log(1);
            }
        })
    }

    function fnBack() {
        // 返回上一页面
        fnDelayCloseWin()
    }
</script>


</html>